import requests
import json
import sys

if '__main__' == __name__:

    argc = len(sys.argv)
    if argc < 3:
        print('Please provide the target IP and port.')
        sys.exit(1)

    xip = sys.argv[1]
    xport = sys.argv[2]

    xjson = dict()
    xjson['input'] = f'{xip}:{xport}'

    # 获取输出
    res = requests.post(f'http://{xip}:{xport}/api', json=xjson, timeout=3)

    # 解析输出
    xjson = json.loads(res.text)
    xoutput = xjson['output']
    print('Output:', xoutput)
